if(!dojo._hasResource["opm.widgets.component.Storage"]){
dojo._hasResource["opm.widgets.component.Storage"] = true;
dojo.provide("opm.widgets.component.Storage");
dojo.require("dijit._Widget");
dojo.require("opm.widgets.Ajax");
dojo.require("opm.widgets.GenericForm");
dojo.require("opm.widgets.GenericPage");
dojo.require("opm.widgets.GenericFormDialog");
dojo.declare("opm.widgets.component.Storage",dijit._Widget,
{
   contentId:"",
   defaultURL:"",
   _GENERIC_ADD_FORM:"opm.widgets.component.Storage.add",

   constructor:function(args){
      this.setAtts(args);
   },
   setAtts:function(args){
      this.contentId = args.contentId;
   },

   showPageDefault:function(){
      var args = {ajaxUrl: 'auth/storage/complete'};
      OPM.ajaxWidget(args, this.contentId).callXhrGet();
   },

   showViewStorage:function(ajaxUrl){
      var args = {ajaxUrl: ajaxUrl, callback: this._initStorageDef};
      OPM.ajaxWidget(args, this.contentId).callXhrGet();
   },

   showAddForm:function(ajaxUrl){
      var dataform = {
         ajaxCallUrl: ajaxUrl, 
         ajaxCallType:'callXhrGetJson',
         contentId: 'center',
         widgetId: this._GENERIC_ADD_FORM
      };
      var genericForm = this.commonForm(dataform);
      genericForm.createForm();
   },

   commonForm:function(dataform){
      var genericForm = OPM.genericFormWidget(dataform);
      genericForm.connectEvent("btnCancelClick", function(data){
          //OPM.storageWidget().showPageDefault();
      });
      genericForm.connectEvent("btnAddClick", function(data){
         genericForm.callSaveForm({
            handleSuccess:function(data){
                alert ("Created this Storage successful");
                OPM.storageWidget().showPageDefault();
                var storageId = data.storageId;
                addStorageNodeItem(storageId, data.displayName);
            }
         });
      });
      return genericForm;
   },
   _initStorageDef:function(){
      dojo.query('#hrefSearchForm').onclick(function(){
         OPM.searchWidget({},'contentSearch').showSearchForm(dojo.byId('viewSearchForm').value);
      });
   }
}
);
}
